Repository navigation
Conversation
96d7dc4 to
cafeeda
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #46439 +/- ##
==========================================
- Coverage 65.80% 65.79% -0.01%
==========================================
Files 3146 3146
Lines 220020 220034 +14
Branches 52111 52107 -4
==========================================
- Hits 144781 144772 -9
- Misses 71807 71825 +18
- Partials 3432 3437 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4d8b2c3 to
8294ff7
Compare
|
Hey @efcasado, thanks for this contribution! 🙏 I just approved the workflows, but also noticed you might need to handle some conflicts. Small feedback on the UI portion: the "Default datetime column" dropdown is already super wide (I don't think we would have column names that big, maybe some exceptions). What do you think about having the "Default time filter" selector next to it (same line) as opposed to under it? I'm curious if that would look better. I'm also going to share this with some folks to get a technical review on the code side. Thanks! |
rebenitez1802
left a comment
There was a problem hiding this comment.
Thanks for this! The feature is narrow and opt-in, and I confirmed that opening an existing saved chart doesn't change its query, so CodeAnt's three comments don't hold up. I found one blocker, plus one thing to watch for when you resolve the conflict with master:
🔴 New charts created from SQL Lab lose DEFAULT_TIME_FILTER. Details and applyable fixes are in the inline comments. Please apply them together as a batch.
🟡 Resolving the messages.pot conflict: running babel_update.sh re-sorted the file and moved "Only admins can delete semantic views." and "Only admins can edit semantic views.". Master has since removed both (#46448), but git's auto-merge keeps the moved copies, and scripts/translations/check_pot_drift.py then fails with "2 string(s) in the template no longer exist in source". After merging master, re-run ./scripts/translations/babel_update.sh on the merged tree, or drop the re-sort and add just the 4 new strings by hand.
8294ff7 to
6d765e4
Compare
Thanks a lot for the feedback, @Vitor-Avila. I will give your suggestion a try shortly and revert back. |
8ed9d88 to
10eade8
Compare
rebenitez1802
left a comment
There was a problem hiding this comment.
Thanks for applying the suggestions, @efcasado! The round-1 issue is fixed: new charts opened from SQL Lab now start with the dataset's default time filter, or DEFAULT_TIME_FILTER when it has none, and saved charts open exactly as on master. The messages.pot rebase is clean too.
CI hasn't run on this commit yet (the workflows need a maintainer's approval), so I ran the checks locally: pot drift, oxlint/oxfmt, type-check, the changed frontend tests, and the dataset backend tests. All pass.
I left two optional, non-blocking suggestions inline.
374104d to
9d32f69
Compare
@Vitor-Avila, I finally found some time to give your suggestion a try. See attached.
If you think this version is better than the one currently implemented, I can push the changes to this PR. The different heights annoys me a bit, but it seems to stem from the style of these two components, i.e. dropdown and date picker, which have different heights. I haven't found any examples where a page would add style overrides to a component. If we are okay doing so, we could do something along the lines of to get something along of what can be seen on the attached picture. Feel a bit hacky to me, but I don't know enough about the project 🙈
Is this what you had in mind? Should I push these changes to the PR? |
9d32f69 to
4ec178f
Compare
|
That's a good question, @efcasado! I think the UI is better this way, but I'm not sure what's the ideal method to perform this override. @rebenitez1802 what would you recommend in this case? |
|
I'd go with the side-by-side version, using For the height, a local override is fine. No theme token matches the Select's height, so this is a deliberate tradeoff. Just keep it in a named styled wrapper next to // Mirrors the Select's rendered height; the date picker defaults to the
// compact Explore height. Remove if the two components are aligned upstream.
const DefaultTimeFilterField = styled(Flex)`
${({ theme }) => css`
width: 100%;
button[name='default_time_filter'] {
height: ${theme.sizeXL + 2 * (theme.sizeUnit + theme.lineWidth)}px;
}
`}
`; |
b66a7a2 to
62de800
Compare
|
@Vitor-Avila, @rebenitez1802 - Thanks for the feedback. The UI changes are ready. Indeed, this version looks more compact and polished! 🙏
|
62de800 to
d4d0372
Compare
…efault_time_filter
…a.time_range Co-authored-by: rebenitez1802 <2151636+rebenitez1802@users.noreply.github.com>
Co-authored-by: Rafael Benitez <rafael.benitez@contractors.food52.com>
Co-authored-by: Rafael Benitez <rafael.benitez@contractors.food52.com>
d4d0372 to
d9fdd94
Compare




SUMMARY
Note
This being my first contribution to the project, I relied on Codex and Claude to 1) get familiar with the project and its codebase, 2) validate the idea, 3) iterate on the solution, and 4) review the changes made. All changes have been reviewed and tested locally using the Docker-ized Superset environment that ships with the project, i.e.
docker compose up --build; which is what has been used to capture the before and after screenshots and the animated gif.We are Preset users and create most of our datasets from templates. Our datasets are defined on tables where an unbounded first query would be expensive and could result in the serving database getting overloaded. I was not aware of the instance-wide
DEFAULT_TIME_FILTERuntil I started looking into this. An instance-wideDEFAULT_TIME_FILTERwouldn't work well for us, though, since the "sensible default" for our datasets is quite volatile and varies from dataset to dataset. Currently, we are solving this using run-time filters we define in SQL and apply when no filter is defined on the default datetime column.This PR is partially related to #13125, which I believe is where this feature was first discussed. The issue was closed when #21879 was merged and added support for instance-wide
DEFAULT_TIME_FILTER. I saw there was a later attempt at adding dataset-level chart defaults, i.e. #34639, which was closed and the whole discussion was put on hold and the team would "revisit how this fits in after the Semantic Layer bits all settle.". The main difference between this PR and previous attempts is that this PR doesn't add chart defaults in general. It only adds a dataset-level counterpart ofDEFAULT_TIME_FILTER.This PR adds a "Default time filter" field in
Edit dataset -> Columns, right next to "Default datetime column" since they are both related. It uses the existing time range picker, and defaults to the instance's global default when unset.Our original idea was to re-use the
main_dttm_colfield and turn it into something along the lines ofbut that would have required schema changes and a DB migration, and would have broken every API consumer and template that reads
main_dttm_colas a column name. It would also have tied the default to a single column, whileDEFAULT_TIME_FILTERapplies to every time filter Explore adds. Thus, I decided to store the value in the dataset'sextraasdefault_time_filter, named afterDEFAULT_TIME_FILTER. This seemed to be the preferred approach in #34639. Besides the dataset editor, the default time filter can also be set in dataset import YAML or through the REST API:BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before

After

Feature in action

NOTES FOR REVIEWERS
The following review notes were suggested by 🤖 Claude:
useDefaultTimeFiltertakes an optional dataset. The filters you add yourself (dragging a column onto Filters, the filter editor), the X-axis time filter prompt and the reset after deleting the last time filter pass it, so they use the dataset's default time filter.hydrateExploregives a new chart without a time filter the dataset's default time filter. When Explore adds a time filter while opening a saved chart,getInitialTimeRangeuses the instance default, so opening the chart doesn't change its query.dynamicPluginControlsReadypasses the same value when a chart plugin loads late.datePickerInAdhocFilterMixin(@superset-ui/chart-controls) uses the dataset's default time filter when it adds a time filter, for example after switching a chart's dataset.getDatasetDefaultTimeFilteris a new public export of that package, andControlPanelStategainsinitialTimeRange, which carries the range hydration chose.dndControls.tsximports the mixins from./mixinsinstead of the package index. This breaks an import cycle that left them undefined in Jest, and doesn't change behaviour in the app.filter.dateFilterControlextension contract gains an optionalplaceholderprop. Existing replacement pickers keep working, but they won't show "Use instance default" until they support it.UpdateDatasetCommandandImportV1DatasetSchema(in the backend) validate the value withget_since_until. An unchanged stored value isn't checked again, so it never blocks an unrelated edit. The deprecated/datasource/save/endpoint doesn't validate it.UPDATING.md. Older Superset versions keep the key inextraand ignore it.creating-your-first-dashboard.mdxdescribes the setting.TESTING INSTRUCTIONS
cleaned_sales_data. In "Columns", set "Default time filter" to a range that covers its data, e.g. from2004-01-01to2005-01-01, and save.order_datestarts with that range.order_dateonto "Filters". The new filter uses the dataset's range. Close it without saving.order_date. The time filter is re-created with that dataset's default time filter, orDEFAULT_TIME_FILTERif it has none.DEFAULT_TIME_FILTER.PUT /api/v1/dataset/<id>with{"extra": "{\"default_time_filter\": \"this is an invalid time range\"}"}. It's rejected with an error onextra. Importing a dataset YAML with an invalid value is rejected the same way.ADDITIONAL INFORMATION